package  com.lenovo.android.syncacc;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Context;

import com.lenovo.android.syncacc.R;
public class MyAndroidAccountManager {
	
	
	 public static Account getNativeAccount(Context context) {

	        //Needs a reference object
	        if(context == null) {
	            return null;
	        }

	        //Retrieve the AccountManager
	        AccountManager am = AccountManager.get(context);
	        Account[] accounts = am.getAccountsByType(context.getString(
	                R.string.account_type));
	        
	        if(accounts != null && accounts.length > 0) {
	            //Return the first element of the account array that matches the
	            //account type for the application
	            return accounts[0];
	        } else {
	            return null;
	        }
	    }

}
